# Maintainer: AndyRTR <andyrtr@archlinux.org>

pkgname=lpsolve
_origname=lp_solve
pkgver=5.5.2.11
_mainver=5.5
pkgrel=2
pkgdesc="a Mixed Integer Linear Programming (MILP) solver"
arch=('loong64' 'x86_64')
url="http://lpsolve.sourceforge.net/" # no https
license=('LGPL2.1')
depends=('glibc')
options=('debug')
source=(https://downloads.sourceforge.net/project/lpsolve/lpsolve/${pkgver}/lp_solve_${pkgver}_source.tar.gz
        flags.patch)
sha1sums=('c0ffa7b8d49938ba213b4d3e894d56b3aba4e983'
          '6fb51fcc2d821f3ca16b0da9e93cf211abafcde2')
sha256sums=('6d4abff5cc6aaa933ae8e6c17a226df0fc0b671c438f69715d41d09fe81f902f'
            '2d374f905a31c17769f52ca57d0e41f39bbe71e84a28f7ab972a63cf380bf14b')

prepare() {
  cd ${_origname}_${_mainver}
  # add CFLAGS/LDFLAGS
  patch -Np1 -i "$srcdir"/flags.patch
}

build() {
  cd ${_origname}_${_mainver}

  # taken from Fedora spec
  cd lpsolve55
  sh -x ccc
#  rm bin/ux*/liblpsolve55.a
  cd ../lp_solve
  sh -x ccc
}

package() {
  cd ${_origname}_${_mainver}

  install -dm755 "${pkgdir}"/usr/{bin,lib,include/lpsolve}
  install -m755 lp_solve/bin/ux*/lp_solve "${pkgdir}"/usr/bin/
  install -m755 lpsolve55/bin/ux*/liblpsolve55.so "${pkgdir}"/usr/lib/
  install -m644 lp*.h "${pkgdir}"/usr/include/lpsolve/
}
